<?php
class UserForm extends Zend_Form
{
	public function __construct($options = null)
	{
		parent::__construct($options);
		$t = Zend_Registry::get('Zend_Translate');

		$this->setname('user');

		$username = new Zend_Form_Element_Text('username');
		$username->setLabel($t->_('username'))
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim');

		$password = new Zend_Form_Element_Password('password');
		$password->setLabel('password')
		->addFilter('StripTags')
		->addValidator('StringLength', false, array(6))
		->addValidator(new validators_matchPasswords());

		$passwordConfirm = new Zend_Form_Element_Password('passwordConfirm');
		$passwordConfirm->setLabel('passwordConfirm')
		->addFilter('StripTags')
		->addValidator('StringLength', false, array(6))
		->addValidator(new validators_matchPasswords());

		$firstname = new Zend_Form_Element_Text('firstname');
		$firstname->setLabel($t->_('firstname'))
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty');

		$surname = new Zend_Form_Element_Text('surname');
		$surname->setLabel($t->_('surname'))
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('NotEmpty');

		$email = new Zend_Form_Element_Text('email');
		$email->setLabel($t->_('email'))
		->setRequired(true)
		->addFilter('StripTags')
		->addFilter('StringTrim')
		->addValidator('EmailAddress');

		$groups = new Zend_Form_Element_Multiselect('groups');
		$groups->setLabel($t->_('groups'));
		$groups->size = 5;

		$id = new Zend_Form_Element_Hidden('id');

		$submit = new Zend_Form_Element_Submit('submit');

		$reset = new Zend_Form_Element_Reset('reset');
		$reset->setLabel('reset');

		$this->addElements(array(
			$username, $password, $passwordConfirm, $firstname, $surname, $email, $groups, $reset, $submit, $id
		));
	}
}